package com.zkingsoft.zkingbase.activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.shareboard.ShareBoardConfig;
import com.zkingsoft.zkingbase.R;
import com.zkingsoft.zkingbase.base.BaseActivity;

import butterknife.OnClick;

public class ShareActivity extends BaseActivity
{


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @OnClick(R.id.btn_share)
    public void onClick()
    {
        ShareBoardConfig config = new ShareBoardConfig();
//        config.setShareboardPostion(ShareBoardConfig.SHAREBOARD_POSITION_CENTER);
        new ShareAction(ShareActivity.this).withText("分享")
                .setDisplayList(
                        SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.WEIXIN_FAVORITE,
                        SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE,
                        SHARE_MEDIA.SINA)
                .setCallback(umShareListener).open();
    }

    private UMShareListener umShareListener = new UMShareListener()
    {
        @Override
        public void onStart(SHARE_MEDIA platform)
        {
            //分享开始的回调
        }

        @Override
        public void onResult(SHARE_MEDIA platform)
        {
            Toast.makeText(ShareActivity.this, platform + " 分享成功啦", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(SHARE_MEDIA platform, Throwable t)
        {
            Toast.makeText(ShareActivity.this, platform + " 分享失败啦", Toast.LENGTH_SHORT).show();
            if (t != null)
            {
            }
        }

        @Override
        public void onCancel(SHARE_MEDIA platform)
        {
            Toast.makeText(ShareActivity.this, platform + " 分享取消了", Toast.LENGTH_SHORT).show();
        }
    };

    @Override
    public int getContentView()
    {
        return R.layout.activity_share;
    }
}
